<?php
session_start();
$pfadTiefe = str_replace($_SERVER['DOCUMENT_ROOT'], "", dirname(__FILE__)."/" ); // alle nötigen PHP funktionen einfügen
$slashCount = substr_count($pfadTiefe, '/'); // Zählen wieviele Slashes drinne sind
$ebeneTiefer = "";
for($i=0; $i<$slashCount; $i++){ // für jeden slash eine ebene tiefergehen
	$ebeneTiefer .= DIRECTORY_SEPARATOR . '..';
}

$pfad = dirname(__FILE__).$ebeneTiefer;
require_once($pfad."/inc/inc_general_php_functions_for_ajax.php");

switch($_POST['type']){
	case "fakeUser":
		switch($_POST['mode']){
			case "fakeSubmittsSimulieren":
				$FakeUser = new FakeUser();
				$ret = $FakeUser->fakeSubmittsSimulieren($_POST['ID'], $_POST['teamWon']);
				break;
			case "resetSubmissions":
				$FakeUser = new FakeUser();
				$ret = $FakeUser->resetSubmissions($_POST['ID']);
				break;
			case "insertUser":
				$FakeUser = new FakeUser();
				$ret = $FakeUser->insertUser($_POST['ID']);
				break;
			case "insertRandomUserinQueue":
				$FakeUser = new FakeUser();
				$ret = $FakeUser->insertRandomUserinQueue();
				break;
			case "submitAllMatchAccept":
				$FakeUser = new FakeUser();
				$ret = $FakeUser->submitAllMatchAccept($_POST['ID']);
				break;
		}
		break;
	case "cronjobs":
		switch($_POST['mode']){
			case "cronjobMatchResultsSubmit":
				$ret = get_include_contents('cronjobs/match/matchResultHandling.php');
				break;
			case "cronjobDoAllCronjobs":
				$ret = get_include_contents('cronjobs/doAllCronjobs.php');
				break;
		}
		break;
		
	
	case "fakeMatches":
		switch($_POST['mode']){
			case "unitTestMatches":
				$FakeMatches = new FakeMatches();
				$ret = $FakeMatches->unitTestMatches();
				break;
			case "insertRandomTestMatches":
				$FakeMatches = new FakeMatches();
				$ret = $FakeMatches->insertRandomTestMatches();
				break;
		}
		break;

}
echo json_encode($ret);
?>